package cn.stu.listener;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSession;

import cn.stu.vo.User;

/**
 * 监听ServletContext对象和销毁的
 * @author zzz
 */
public class MyServletContextListener implements ServletContextListener {
	 //ServletContext对象一创建，这个方法就会执行
	 //ServletContextEvent 事件对象，  监听器对象----》监听ServletContext(事件源)
	//事件对象可以获得事件源对象
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		Map<User, HttpSession> userMap = new HashMap<User, HttpSession>();	
		sce.getServletContext().setAttribute("userMap", userMap);
	
	}
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	

}
